

.global reset_vector


.section ".arm_vector", "ax"

__boot_stage2:
	.byte  0x00, 0xb5, 0x32, 0x4b, 0x21, 0x20, 0x58, 0x60,  0x98, 0x68, 0x02, 0x21, 0x88, 0x43, 0x98, 0x60
	.byte  0xd8, 0x60, 0x18, 0x61, 0x58, 0x61, 0x2e, 0x4b,  0x00, 0x21, 0x99, 0x60, 0x04, 0x21, 0x59, 0x61 
	.byte  0x01, 0x21, 0xf0, 0x22, 0x99, 0x50, 0x2b, 0x49,  0x19, 0x60, 0x01, 0x21, 0x99, 0x60, 0x35, 0x20 
	.byte  0x00, 0xf0, 0x44, 0xf8, 0x02, 0x22, 0x90, 0x42,  0x14, 0xd0, 0x06, 0x21, 0x19, 0x66, 0x00, 0xf0 
	.byte  0x34, 0xf8, 0x19, 0x6e, 0x01, 0x21, 0x19, 0x66,  0x00, 0x20, 0x18, 0x66, 0x1a, 0x66, 0x00, 0xf0 
	.byte  0x2c, 0xf8, 0x19, 0x6e, 0x19, 0x6e, 0x19, 0x6e,  0x05, 0x20, 0x00, 0xf0, 0x2f, 0xf8, 0x01, 0x21 
	.byte  0x08, 0x42, 0xf9, 0xd1, 0x00, 0x21, 0x99, 0x60,  0x1b, 0x49, 0x19, 0x60, 0x00, 0x21, 0x59, 0x60 
	.byte  0x1a, 0x49, 0x1b, 0x48, 0x01, 0x60, 0x01, 0x21,  0x99, 0x60, 0xeb, 0x21, 0x19, 0x66, 0xa0, 0x21 
	.byte  0x19, 0x66, 0x00, 0xf0, 0x12, 0xf8, 0x00, 0x21,  0x99, 0x60, 0x16, 0x49, 0x14, 0x48, 0x01, 0x60 
	.byte  0x01, 0x21, 0x99, 0x60, 0x01, 0xbc, 0x00, 0x28,  0x00, 0xd0, 0x00, 0x47, 0x12, 0x48, 0x13, 0x49 
	.byte  0x08, 0x60, 0x03, 0xc8, 0x80, 0xf3, 0x08, 0x88,  0x08, 0x47, 0x03, 0xb5, 0x99, 0x6a, 0x04, 0x20 
	.byte  0x01, 0x42, 0xfb, 0xd0, 0x01, 0x20, 0x01, 0x42,  0xf8, 0xd1, 0x03, 0xbd, 0x02, 0xb5, 0x18, 0x66 
	.byte  0x18, 0x66, 0xff, 0xf7, 0xf2, 0xff, 0x18, 0x6e,  0x18, 0x6e, 0x02, 0xbd, 0x00, 0x00, 0x02, 0x40 
	.byte  0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x07, 0x00,  0x00, 0x03, 0x5f, 0x00, 0x21, 0x22, 0x00, 0x00 
	.byte  0xf4, 0x00, 0x00, 0x18, 0x22, 0x20, 0x00, 0xa0,  0x00, 0x01, 0x00, 0x10, 0x08, 0xed, 0x00, 0xe0 
	.byte  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00, 0x07, 0x0b, 0x8f, 0xd5 


.global _exception_vectors
_exception_vectors:

    .word	0x20042000				    // init sp, msp
    .word   Reset_Handler	            // Reset Handler
    .word   NMI_Handler                 // NMI Handler
    .word   HardFault_Handler           // Hard Fault Handler
    .word   0           				// Reserved
    .word   0            				// Reserved
    .word   0          					// Reserved
    .word   0                           // Reserved
    .word   0                           // Reserved
    .word   0                           // Reserved
    .word  	0                           // Reserved
    .word   SVC_Handler                 // SVCall Handler
    .word   0            				// Debug Monitor Handler
    .word   0                           // Reserved
    .word   PendSV_Handler            	// PendSV Handler
    .word   SysTick_Handler           	// SysTick Handler

	/* hc32l110 soc, vector table. */
	
    .word   Default_Handler				// 0
    .word   0                		    // 1
    .word   0                           // 2
    .word   0                           // 3
    .word   0                           // 4
    .word   0                           // 5
    .word   0                           // 6
    .word   0                           // 7
    .word   0                           // 8
    .word   0                           // 9
    .word   0               		    // 10
    .word   0                           // 11
    .word   0                           // 12
    .word   0                           // 13
    .word   0                           // 14
    .word   0                           // 15    
   


// void __aeabi_memclr ( void *dest, size_t n );
// void __aeabi_memcpy ( void *dest, const void *src, size_t n );

.section ".text", "ax"


.type Reset_Handler,%function
.type NMI_Handler,%function

NMI_Handler:
Reset_Handler:

	ldr     r0, =__data_start
	ldr     r1, =__dummy_end
	ldr     r2, =__data_size
	mov     r7, r2
	bl      __aeabi_memcpy

	add     r0, r7
	ldr     r1, =__bss_size
	bl      __aeabi_memclr


    LDR     R0, =SystemInit
    BLX     R0
    LDR     R0, =main
    BLX     R0


1:	nop
	nop
	b		1b
	

.type HardFault_Handler,%function

HardFault_Handler:
MemManage_Handler:
BusFault_Handler:
UsageFault_Handler:
	b		.
	nop


.type SVC_Handler,%function
SVC_Handler:
DebugMon_Handler:
	b		.
	nop


.type PendSV_Handler,%function
PendSV_Handler:
	b		.
	nop

.type Default_Handler,%function
Default_Handler:
	b		.
	nop
	




